<div class="container">
	<h1 ng-controller="getUser">Hello {{user.name}}</h1>
	<div class="row" ng-controller="Items">
		<div class="col-md-4">
			<table class="table table-striped">
				<th>
					<tr>
						<td>name</td>
						<td>sum</td>
						<td>
							<div class="dropdown">
							  	<button class="btn btn-success dropdown-toggle" data-toggle="dropdown">
							    <span class="caret"></span>
							  	</button>
							  	<ul class="dropdown-menu">
							    	<li><a tabindex="-1" ng-click="getsand(null,1,1);">View total details</a></li>
							    	<li><a tabindex="-1" ng-click="getItemsAll();">Show all items</a></li>
							    	<li class="divider"></li>
							    	<li><a tabindex="-1" href="" ng-click="addnewitem();">Add new Item</a></li>
							  	</ul>
							</div>
						</td>
					</tr>
				</th>
				<tr ng-hide="addnewitem_hide">
					<form method="POST" ng-submit="addnewitem();">
						<td class="span2" colspan="2">
							<input type="text" ng-model="newitemname" class="form-control" placeholder="新项目名称"/>
						</td>
						<td><input type="submit" class="btn btn-default" value="OK"/></td>
					</form>
				</tr>
				<tr ng-repeat="item in items" >
					<td class="span2">{{item.name}}</td>
					<td class="span2">{{item.sum==null?0:item.sum}}</td>
					<td class="span3">
						<div class="btn-group">
						  	<button class="btn btn-default" ng-click="getsand('{{item.name}}',1,1);">Details</button>
						  	<button class="btn btn-default dropdown-toggle" data-toggle="dropdown"><span class="caret"></span></button>
						  	<ul class="dropdown-menu pull-right">
						    	<li><a ng-click="hideitem('{{item.name}}',-1)">Delete item</a></li>
						    	<li><a ng-click="hideitem('{{item.name}}',0)">Hide item</a></li>
						  	</ul>
						</div>
					</td>
				</tr>
			</table>
		</div>
		
		<div class="col-md-8" ng-hide="viewdetail_hide">
			<span ng-hide="true">{{itemname}}</span>
			<div>
				<span ng-hide="true">{{pageindex}}</span>
				<span ng-hide="true">{{totalpages}}</span>
				<ul class="pagination pagination-sm">
				  <li class="{{pageindex==1?'disabled':''}}"><a ng-click="getsand(null,pageindex-1,0);">&laquo;</a></li>
				  <li class="{{pageindex==page.pagenum?'active':''}}" ng-repeat="page in pages"><a ng-click="getsand(null,{{page.pagenum}},0);">{{page.pagenum}}</a></li>
				  <li class="{{totalpages<=pageindex?'disabled':''}}"><a ng-click="getsand(null,pageindex+1,0);">&raquo;</a></li>
				</ul>
			</div>
			<table class="table table-bordered table-striped table-condensed">
				<th>
					<tr><td>name</td><td>time(hour)</td><td>datatime</td><td>comments</td></tr>
				</th>
				<tr ng-repeat="sand in sands" >
					<td class="col-md-1">{{sand.name}}</td>
					<td class="col-md-1">{{sand.time}}</td>
					<td class="col-md-3">{{sand.datetime|date:'yyyy-MM-dd HH:mm:ss'}}</td>
					<td style="text-align: left;">{{sand.comments}}</td>
				</tr>
				<tr ng-hide="addnewsand_hide">
					<form method="POST" ng-submit="addnewitem();">
						<td>
							<input type="number" ng-model="timespend" class="input-small" placeholder="time spend">
						</td>
						<td colspan="3">
							<input type="text" ng-model="comment" class="input-xlarge" placeholder="please input your comments"/>
						</td>
						<input type="submit" class="btn" value="OK" ng-hide="true"/>
					</form>
				</tr>
			</table>
			<button class="btn btn-warning pull-right" style="margin: 5px;" ng-click="closedetail();" ng-hide="itemname==null">close</button>
			<button class="btn btn-info pull-right" style="margin: 5px;" ng-click="addsand();" ng-hide="itemname==null">add</button>
		</div>
	</div>	
</div>